package cjq.demo.thread.ch4_10;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2016/4/30.
 */
public class ExecutableTask implements Callable<String> {

    private String name;

    public String getName(){
        return name;
    }

    public ExecutableTask(String name){
        this.name = name;
    }


    public String call() throws Exception{
        try{
            long duration = (long)(Math.random()*10);
            System.out.println(this.name+" : Waiting "+duration+" seconds for results.");
            TimeUnit.SECONDS.sleep(duration);
        }catch (InterruptedException e){}

        return "Hello, world . I'm "+name;

    }
}
